import { Injectable } from '@angular/core';
import { BaseService } from '@core/routes-services/base.service';
import { CacheService } from '@core/routes-services/cache.service';
import { HttpClient } from '@angular/common/http';

/**
 * 奖励积分记录 服务
 */
@Injectable()
export class IntegralRecordService extends BaseService {

  constructor(http: HttpClient, cacheService: CacheService) {
    super(http, cacheService);
  }

  base_url: any = 'api/integral/record';


  /**
   * 分页
   *
   * @param user
   * @returns {Promise<any>}
   */
  pagination(page: any, keyword: any,type:any): Promise<any> {
    const url = this.base_url + '/pagination';
    if(keyword){
      page['_filter_like_keyword'] = keyword;
    }
    if(type){
      page['_filter_eq_type'] = type;
    }
    page['_sort_by_'] = "saveTime_desc";
    return this.post(url, page);
  }

  /**
   * 获取查看详情
   *
   * @param id
   * @returns {Promise<any>}
   */
  detail(id: any): Promise<any> {
    const url = this.base_url + '/' + id;
    return this.get(url);
  }
  /**
   * 获取全部
   *
   * @returns {Promise<any>}
   */
  getAll(): Promise<any> {
    const url = this.base_url + '/all';
    return this.get(url);
  }
}
